import type {
	Address,
	OrderPre,
	MedicalOrderDetail,
	OrderQuery,
	OrderListData,
	ExpressData,
} from '@/types/order.d.ts'
import { request } from '@/utils/request'

/**
 * 收货地址列表
 */
export const addressListApi = () => {
	return request.get<null, Address[]>('/patient/order/address')
}

/**
 * 药品预付订单
 * prescriptionId:处方Id
 */
export const preOrderApi = (prescriptionId: string) => {
	return request.get<null, OrderPre>('/patient/medicine/order/pre', {
		params: { prescriptionId },
	})
}

/**
 * 药品待支付订单
 * id:处方 id
 * addressId: 地址id
 */
export const createOrderApi = (id: string, addressId: string) => {
	return request.post<any, { id: string }>('/patient/medicine/order', { id, addressId })
}

/**
 * 获取药品订单详情
 * @param id 订单id
 * @returns
 */
export const getMedicalOrderDetail = (id: string) =>
	request.get<any, MedicalOrderDetail>(`/patient/medicine/order/detail/${id}`)

/**
 * 医生问诊列表
 */
export const orderListApi = (data: OrderQuery) => {
	return request.get<null, OrderListData>('/patient/consult/order/list', { params: data })
}

// 获取药品订单物流信息
export const getMedicalOrderLogistics = (id: string) =>
	request.get<any, ExpressData>(`/patient/order/${id}/logistics`)
